package com.xbao.dao;

import com.xbao.model.EmpOrgRel;
import com.xbao.model.EmpOrgRelExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface EmpOrgRelMapper {
    @SelectProvider(type=EmpOrgRelSqlProvider.class, method="countByExample")
    int countByExample(EmpOrgRelExample example);

    @DeleteProvider(type=EmpOrgRelSqlProvider.class, method="deleteByExample")
    int deleteByExample(EmpOrgRelExample example);

    @Delete({
        "delete from emp_org_rel",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into emp_org_rel (eid, oid, ",
        "mainflag)",
        "values (#{eid,jdbcType=BIGINT}, #{oid,jdbcType=BIGINT}, ",
        "#{mainflag,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(EmpOrgRel record);

    @InsertProvider(type=EmpOrgRelSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(EmpOrgRel record);

    @SelectProvider(type=EmpOrgRelSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="eid", property="eid", jdbcType=JdbcType.BIGINT),
        @Result(column="oid", property="oid", jdbcType=JdbcType.BIGINT),
        @Result(column="mainflag", property="mainflag", jdbcType=JdbcType.INTEGER)
    })
    List<EmpOrgRel> selectByExample(EmpOrgRelExample example);

    @Select({
        "select",
        "id, eid, oid, mainflag",
        "from emp_org_rel",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="eid", property="eid", jdbcType=JdbcType.BIGINT),
        @Result(column="oid", property="oid", jdbcType=JdbcType.BIGINT),
        @Result(column="mainflag", property="mainflag", jdbcType=JdbcType.INTEGER)
    })
    EmpOrgRel selectByPrimaryKey(Long id);

    @UpdateProvider(type=EmpOrgRelSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") EmpOrgRel record, @Param("example") EmpOrgRelExample example);

    @UpdateProvider(type=EmpOrgRelSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") EmpOrgRel record, @Param("example") EmpOrgRelExample example);

    @UpdateProvider(type=EmpOrgRelSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(EmpOrgRel record);

    @Update({
        "update emp_org_rel",
        "set eid = #{eid,jdbcType=BIGINT},",
          "oid = #{oid,jdbcType=BIGINT},",
          "mainflag = #{mainflag,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(EmpOrgRel record);
}